/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package business;

import dal.PlacesDAL;
import java.util.ArrayList;
import java.util.List;
import model.Places;

/**
 *
 * @author Administrator
 */
public class PlacesBusiness {
    private PlacesDAL placesDAL = new PlacesDAL();

    public boolean newPlaces(Places place){
        if(placesDAL.newPlaces(place)){
            return true;
        }
        return false;
    }

    public boolean updatePlaces(Places place){
        if(placesDAL.updatePlaces(place)){
            return true;
        }
        return false;
    }

    public List<Places> listPlacesByLocalID(int localID){
        return placesDAL.listPlacesByLocalID(localID);
    }

    public List<Places> listAllPlaces(){
        return placesDAL.listAllPlace();
    }

    public int getRowInListAllPlaces(){
        return placesDAL.listAllPlace().size();
    }

    public List<Places> listPlaceByPage(int pageID){
        List<Places> listAll = placesDAL.listAllPlace();
        List<Places> listByPage = new ArrayList<Places>();
        for(int i=(pageID-1)*4; i<(pageID*4);i++){
            try {
                listByPage.add(listAll.get(i));
            } catch (IndexOutOfBoundsException ex) {
                return listByPage;
            }
        }
        return listByPage;
    }
}
